﻿using AutoMapper;
using Superadmin.Net.IService;
using Superadmin.Net.Repository.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Superadmin.Net.Service
{
    public class BaseServices<TEntity, Tvo> : IBaseServices<TEntity, Tvo> where TEntity : class, new()
    {
        private readonly IMapper _mapper;
        private readonly IBaseRepository<TEntity> _baseRepository;

        public BaseServices(IMapper mapper,
            IBaseRepository<TEntity> baseRepository)
        { 
            _mapper = mapper;
            _baseRepository = baseRepository;
        }

        public async Task<List<Tvo>> Query()
        {
            var entities = await _baseRepository.Query();
            var llout = _mapper.Map<List<Tvo>>(entities);
            return llout;
        }

    }
}
